var kfConfig = {
    icon:'',
    width:'50px',
    height:'80px',
    top:'70px',
    right:'5%',
    link:'',
    text:'客服',
    textVisible:true
};

if (document.currentScript) {
    kfConfig.icon = document.currentScript.getAttribute("icon")||kfConfig.icon;
    kfConfig.width = document.currentScript.getAttribute("w")||kfConfig.width;
    kfConfig.height = document.currentScript.getAttribute("h")||kfConfig.height;
    kfConfig.top = document.currentScript.getAttribute("t")||kfConfig.top;
    kfConfig.right = document.currentScript.getAttribute("r")||kfConfig.right; 
    kfConfig.link = document.currentScript.getAttribute("link")|| kfConfig.link;
    kfConfig.text = document.currentScript.getAttribute("text")||kfConfig.text;
    kfConfig.textVisible = document.currentScript.getAttribute("textvisible")!=="false";
}

/**
 * 
 */
var _kf_initial = function()
{  
    var kf_box = document.createElement('div'); 
    kf_box.style.position="fixed";
    kf_box.style.display = "flex";
    kf_box.style.flexFlow = "column";
    kf_box.style.justifyContent = "center";
    kf_box.style.alignItems = "center";
    kf_box.style.width = kfConfig.width;
    kf_box.style.height = kfConfig.height; 
    kf_box.style.top = kfConfig.top;
    kf_box.style.right = kfConfig.right;
    kf_box.style.fontSize = "80%";
    kf_box.style.lineHeight = "30px";
    kf_box.style.cursor = "pointer";   
    kf_box.style.backgroundColor = "transparent"; 
    
    var link  = document.createElement('a'); 
    link.style.border = "1px #a8a7a7 solid"; 
    link.style.width = "50px";
    link.style.height = "50px"; 
    link.style.borderRadius = "5px";
    link.style.cursor = "pointer"; 
    link.style.display = "block"; 
    link.style.backgroundColor = "transparent"; 
    link.href = kfConfig.link;

    if(kfConfig.icon.length > 0)
    {
        link.style.backgroundImage = "url("+kfConfig.icon+")";
        link.style.backgroundPosition = "center";
        link.style.backgroundSize = "70%";
        link.style.backgroundRepeat = "no-repeat"; 
    }
    kf_box.appendChild(link);
     
    if(kfConfig.textVisible)
    {
        var label = document.createElement('label');
        label.innerHTML = kfConfig.text;
        label.style.color = "#524c4c9e";
        label.style.fontSize= "80%"; 
        label.style.bottom = "0px";
        label.style.width = "100%";
        label.style.textAlign = "center";
     
        kf_box.appendChild(label);
    }
     
    document.body.appendChild(kf_box); 
     
};

window.addEventListener('load',_kf_initial);